<template>
    <div>
        <el-card>
            <myReturn></myReturn>
            <el-form label-position="top" label-width="80px" :model="formLabelAlign">
                <el-row :gutter="20">
                    <el-col :span="12">
                        <el-form-item>
                            <span slot="label">
                                <span class="label-text">标题名称</span>

                            </span>
                            <el-input v-model="formLabelAlign.name"></el-input>
                        </el-form-item>
                        <el-form-item>
                            <span slot="label">
                                <span class="label-text">下一步</span>

                            </span>
                            <el-select v-model="value" placeholder="请选择" style="width:100%">
                                <el-option v-for="item in options" :key="item.value" :label="item.label"
                                    :value="item.value">
                                </el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item>
                            <span slot="label">
                                <span class="label-text">审批人</span>
                            </span>
                            <el-input v-model="formLabelAlign.type">
                                <el-button slot="suffix" icon="el-icon-plus" type="success" size="mini"
                                    @click="dialogVisible = true">审批人</el-button>
                            </el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item>
                            <span slot="label">
                                <span class="label-text">到期</span>

                            </span>
                            <el-date-picker v-model="value1" type="datetime" placeholder="选择日期时间" style="width:100%">
                            </el-date-picker>
                        </el-form-item>
                        <el-form-item>
                            <span slot="label">
                                <span class="label-text">紧张程度</span>

                            </span>
                            <el-select v-model="value" placeholder="请选择" style="width:100%">
                                <el-option v-for="item in options" :key="item.value" :label="item.label"
                                    :value="item.value">
                                </el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item>
                            <span slot="label">
                                <span class="label-text">抄送人</span>
                            </span>
                            <el-input v-model="formLabelAlign.type">
                                <el-button slot="suffix" icon="el-icon-plus" type="success" size="mini"
                                    @click="dialogVisible1 = true">抄送人</el-button>
                            </el-input>
                        </el-form-item>
                    </el-col>

                </el-row>
                <el-form-item class="sub-btn">
                    <el-button type="primary"  @click="myReturn()">保存</el-button>
                    <el-button @click="myReturn()">取消</el-button>
                </el-form-item>

            </el-form>
            <el-dialog :visible.sync="dialogVisible" width="30%" :before-close="handleClose">
                <searchSend ></searchSend>
                <el-table :data="currentPageData" style="width: 100%" :default-sort="{ prop: 'date', order: 'descending' }"
                    tooltip-effect="dark">
                    <el-table-column prop="date" label="部门" sortable width="180">
                    </el-table-column>
                    <el-table-column prop="name" label="真实姓名" sortable width="180">
                    </el-table-column>
                    <el-table-column prop="address" label="用户名" sortable></el-table-column>
                    <el-table-column prop="address" label="角色" sortable></el-table-column>
                    <el-table-column prop="address" label="电话"></el-table-column>
                    <el-table-column fixed="right" label="操作" width="100">
                        <template slot-scope="scope">
                            <el-button type="success" icon="el-icon-plus" size="mini" @click="addClassification">设为审批人</el-button>
                        </template>
                    </el-table-column>
                </el-table>
                <pager :page=page :limit=limit :total=total :lastPage=lastPage @handleSizeChange="handleSizeChange"
                    @toLastPage="toLastPage" @toFirstPage="toFirstPage" @handleCurrentChange="handleCurrentChange"></pager>

                <span slot="footer" class="dialog-footer">
                    <el-button @click="dialogVisible = false">取 消</el-button>
                    <el-button type="primary" @click="dialogVisible = false">确 定</el-button>
                </span>
            </el-dialog>
            <el-dialog :visible.sync="dialogVisible1" width="30%" :before-close="handleClose1">
                <searchApproval></searchApproval>
                <el-table :data="currentPageData" style="width: 100%" :default-sort="{ prop: 'date', order: 'descending' }"
                    tooltip-effect="dark" @selection-change="handleSelectionChange">
                    <el-table-column type="selection" width="55">
                    </el-table-column>
                    <el-table-column prop="date" label="部门" sortable width="180">
                    </el-table-column>
                    <el-table-column prop="name" label="真实姓名" sortable width="180">
                    </el-table-column>
                    <el-table-column prop="address" label="用户名" sortable></el-table-column>
                    <el-table-column prop="address" label="角色" sortable></el-table-column>
                    <el-table-column prop="address" label="电话"></el-table-column>
                </el-table>
                <pager :page=page :limit=limit :total=total :lastPage=lastPage @handleSizeChange="handleSizeChange"
                    @toLastPage="toLastPage" @toFirstPage="toFirstPage" @handleCurrentChange="handleCurrentChange"></pager>

                <span slot="footer" class="dialog-footer">
                    <el-button @click="dialogVisible = false">取 消</el-button>
                    <el-button type="primary" @click="dialogVisible = false">确 定</el-button>
                </span>
            </el-dialog>
        </el-card>

    </div>
</template>

<script>
import pager  from "@/views/WorkFlow/MyWork/components/pager.vue";
import searchSend from "@/views/WorkFlow/MyWork/components/addwork/searchSend.vue";
import searchApproval  from "@/views/WorkFlow/MyWork/components/addwork/searchApproval.vue";
import myReturn  from "@/views/WorkFlow/MyWork/components/addwork/myreturn.vue";
export default {
    name: "addWork",
    data() {
        return {
            options: [{
                value: '选项1',
                label: '公章'
            }, {
                value: '选项2',
                label: '私章'
            },],
            value: '',
            formLabelAlign: {
                name: '',
                region: '',
                type: ''
            },
            value1:"",
            dialogVisible: false,
            dialogVisible1: false,
            page: 1,
            limit: 3,
            lastPage: 0,
            total: 0,
            currentPageData: [], //当前页显示内容
            tableData: [{
                date: '2016-05-02',
                name: '王小虎',
                address: '上海市普陀区金沙江路 1518 弄'
            }, {
                date: '2016-05-04',
                name: '王小虎',
                address: '上海市普陀区金沙江路 1517 弄'
            }, {
                date: '2016-05-01',
                name: '王小虎',
                address: '上海市普陀区金沙江路 1519 弄'
            }, {
                date: '2016-05-03',
                name: '王小虎',
                address: '上海市普陀区金沙江路 1516 弄'
            }],
        }
    }
    ,
    methods: {
        handleClose(done) {
            this.$confirm('确认关闭？')
                .then(_ => {
                    done();
                })
                .catch(_ => { });
        },
        handleClose1(done) {
            this.$confirm('确认关闭？')
                .then(_ => {
                    done();
                })
                .catch(_ => { });
        },
        handleSelectionChange(val) {
            this.multipleSelection = val;
        },
        handleSizeChange(val) {
            this.limit = val;
            this.lastPage = Math.ceil(this.tableData.length / this.limit);
            this.getCurrentPageData()
        },
        getCurrentPageData() {
            let begin = (this.page - 1) * this.limit;
            let end = this.page * this.limit;
            this.currentPageData = this.tableData.slice(begin, end)
        },
        toLastPage(val) {
            this.page = val;
            this.getCurrentPageData()
        },
        toFirstPage(val) {
            this.page = val;
            this.getCurrentPageData()
        },
        handleCurrentChange(val) {
            this.page = val;
            this.getCurrentPageData(val)
        },
        myReturn(){
                this.$router.push("/myWork")
            } 
    },
    created() {
        this.lastPage = Math.ceil(this.tableData.length / this.limit)
        this.total = this.tableData.length
        this.getCurrentPageData();
    },
    components:{
        pager,
        searchSend ,
        searchApproval,
        myReturn
    }
}
</script>

<style  scoped>
.label-text {
    font-weight: 700;
    font-size: 14px;
    color: #333;
}

.sub-btn {
    margin-top: 20px;
    text-align: left;
};

</style>